<%--
  Created by IntelliJ IDEA.
  User: dqf
  Date: 2014/12/10
  Time: 16:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://"
          + request.getServerName() + ":" + request.getServerPort()
          + path + "/";
%>
<div class="row">
  <!-- NEW WIDGET START -->
  <article class="col-sm-12 col-md-12 col-lg-12">
    <div class="jarviswidget well" id="wid-id-3"
         data-widget-colorbutton="false"
         data-widget-editbutton="false"
         data-widget-togglebutton="false"
         data-widget-deletebutton="false"
         data-widget-fullscreenbutton="false"
         data-widget-custombutton="false"
         data-widget-sortable="false">
      <!-- widget div-->
      <div>
        <div class="widget-body">
          <a class="btn btn-default" id="btn-re-common" href="javascript:void(0)">
            <i class="fa fa-lg fa-mail-reply-all"></i>初步设计登记表
          </a>

          <s:if test="design==null || design.getProcessState().name()=='Draft'">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-confirm-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 提交</a>
          </s:if>
          <s:if test="design.getProcessState().name()=='Backed'">
            <a class="btn btn-default pull-right pull-right-fix" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-rocket"></i> 再提交</a>
          </s:if>

          <a class="btn btn-default pull-right pull-right-fix" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存</a>
          <hr class="simple">
          <form id="design" class="smart-form" novalidate="novalidate" action="" method="post">
            <input type="hidden" name="keyId" id="keyId" value="<s:property value="design.id" />"/>
            <input type="hidden" name="curDutyId" id="curDutyId" value="<s:property value="curDutyId" />"/>

            <header id="title" style="display: block;">
              初步设计登记表
              <a href="javascript:void(0);" key="btn-outcome-comment">
                                    <span class="txt-color-blueDark pull-right">
                                        <i class="fa-fw fa fa-comment-o"></i> 审批意见<span></span>
                                    </span>
              </a>
            </header>
            <fieldset>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  项目名称
                </label>
                <section class="col col-5">
                  <label class="input">
                    <select name="projectId" class="form-control" id="projectId">
                      <option value="">请选择</option>
                      <s:iterator value="projectArrayList" id="list">
                        <option  value="<s:property value="#list.id"/>" <s:property value="#list.selected"/> >
                          <s:property value="#list.name"/>
                        </option>
                      </s:iterator>
                    </select>
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">
                  <i class="fa fa-asterisk txt-color-red"></i>
                  对应招标结果表
                </label>
                <section class="col col-5">
                  <label class="input">
                    <select name="bidresultId" class="form-control" id="bidresultId">
                      <option value="">请选择</option>
                      <s:iterator value="bidresultArrayList" id="list">
                        <option  value="<s:property value="#list.id"/>" <s:property value="#list.selected"/> >
                          <s:property value="#list.name"/>
                        </option>
                      </s:iterator>
                    </select>
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">初步设计批复</label>
                <section class="col col-5">
                  <label class="input">
                    <input  name="uploadify" id="file_upload" placeholder="" type="file" >
                    <input name="fileIdA" id="fileIdA" style="display: none" value="<s:property value="design.fileId"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">批复概算金额</label>
                <section class="col col-4">
                  <label class="input">
                    <input name="replyMoney" id="replyMoney" placeholder="请输入批复概算金额"
                           type="number" value="<s:property value="design.replyMoney"/>">
                  </label>
                </section>
                <label class="label col money-unit-form">万元</label>
              </div>
              <div class="row">
                <label class="label col col-2">批复日期</label>
                <section class="col col-2">
                  <label class="input">
                    <i class="icon-append fa fa-calendar"></i>
                    <input class="hasDatepicker" name="replyDate" id="replyDate" placeholder="请选择批复日期"
                           type="text" value="<s:date name="design.replyDate" format="yyyy-MM-dd"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">相关文号</label>
                <section class="col col-5">
                  <label class="input">
                    <input name="relateNo" id="relateNo" placeholder="请输入备注"
                           type="text" value="<s:property value="design.relateNo"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">其他专项审查上传</label>
                <section class="col col-5">
                  <label class="input">
                    <input  name="uploadify" id="file_upload1" placeholder="" type="file" >
                    <input name="fileId1" id="fileId1" style="display: none" value="<s:property value="design.othierFileId"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">备注</label>
                <section class="col col-5">
                  <label class="input">
                    <input name="mark" id="mark" placeholder="请输入备注"
                           type="text" value="<s:property value="design.mark"/>">
                  </label>
                </section>
              </div>
              <div class="row">
                <label class="label col col-2">提交人</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
                <label class="label col col-1">提交日期</label>
                <section class="col col-2">
                  <label class="input state-disabled">
                    <input value="" placeholder="" type="text" disabled="disabled">
                  </label>
                </section>
              </div>
            </fieldset>
          </form>
        </div>
      </div>
    </div>
  </article>
</div>

<script>
  /*
   $("#isDelegate").onchange(function(){
   if (this.getAttr("isChecked") == "isChecked"){
   $("#hidediv").setAttr("style","display:none");
   }
   else{
   $("#hidediv").setAttr("style","display:block");
   }
   });
   */
  //返回视图
  $("#btn-re-common").click(function(){
    loadURL("ajax!design.action",$('#content'));
  });
  //校验
  $("#design").validate({
    rules : {
      projectId : {
        required : true
      },
      bidresultId : {
        required : true
      }
    },
    messages : {
      projectId : {
        required : '请输入项目名称'
      },
      bidresultId : {
        required : '请输入招标结果表'
      }
    },
    errorPlacement : function(error, element) {
      error.insertAfter(element.parent());
    }
  });

  $('.hasDatepicker').datetimepicker({
    format: 'yyyy-mm-dd',
    weekStart: 1,
    autoclose: true,
    todayBtn: 'linked',
    language: 'zh-CN',
    minView:2
  });
  //保存
  $("#btn-save-common").click(
          function(e) {
            var $valid = $("#design").valid();
            if(!$valid){
              e.preventDefault();
              e.stopPropagation();
              return;
            }
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                $("#btn-save-common").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!save.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );
  //提交
  $("#btn-confirm-common").click(
          function(e) {
            var $valid = $("#design").valid();

            if(!$valid){
              e.preventDefault();
              e.stopPropagation();
              return;
            }
            $.SmartMessageBox({
              title : "提示：",
              content : "确定提交申请吗？",
              buttons : '[取消][确认]'
            }, function(ButtonPressed) {
              if (ButtonPressed === "取消") {
                e.preventDefault();
                e.stopPropagation();
                return;
              }
              if (ButtonPressed === "确认") {
                var $validForm = $("#design").valid();
                if(!$validForm) return false;
                $("#btn-confirm-common").attr("disabled", "disabled");
                form_save("design","<%=path%>/com/ajax-design!commit.action");
                loadURL("ajax!design.action",$('#content'));
              }
            });
          }
  );
  $("#btn-recommit-common").unbind().bind("click",function(e){
    var $valid = $("#design").valid();

    if(!$valid){
      e.preventDefault();
      e.stopPropagation();
      return;
    }
    $.SmartMessageBox({
      title : "提示：",
      content : "确定再次提交申请吗？",
      buttons : '[取消][确认]'
    }, function(ButtonPressed) {
      if (ButtonPressed === "取消") {
        e.preventDefault();
        e.stopPropagation();
        return;
      }
      if (ButtonPressed === "确认") {
        var $validForm = $("#design").valid();
        if(!$validForm) return false;
        $("#btn-recommit-common").attr("disabled", "disabled");
        form_save("design","<%=path%>/com/ajax-design!commit.action");
        loadURL("ajax!design.action",$('#content'));
      }
    });
  });

  //上传文件
  inputLoad({
    objId:"file_upload",
    entityName:"fileId",
    sourceId:"fileIdA"
  });

  inputLoad({
    objId:"file_upload1",
    entityName:"othierFileId",
    sourceId:"fileId1"
  });

</script>
<script type="text/javascript">
$(function(){multiDuty()});

  $("select#projectId").unbind().bind("change",function(){
    var id = $("select#projectId").val();
    $("select#bidresultId").empty();
    $("<option value=''>请选择</option>").appendTo("select#bidresultId");
    var data={projectId:id};
    $.ajax({
      url : "ajax-design!showResult.action",
      method:"post",
      cache : false,
      dataType : "json",
      async : false,
      data : data,
      success : function(data) {
        var data = eval(data.rows);
        $(data).each(function(index,value){
          var str = "<option value="+value.id+">"+value.name+"</option>";
          $(str).appendTo("select#bidresultId");
        });
      }
    });
});
</script>
